package com.iweb.day06.factory;

/**
 * @author jay
 * @date 2021/11/2
 * @description
 */
public class SimpleFactory {

    /**
     * 创建子类产品
     * @param operator
     * @return
     */
    public static Operation createOperation(String operator) {
        Operation operation = null;

        // 判断运算符, 根据不同的运算需求, 实例化对应的子类对象,来提供服务
        switch (operator) {
            case "+":
                operation = new OperationAdd();
                break;
            case "-":
                operation = new OperationSub();
                break;
            case "*":
                operation = new OperationMul();
                break;
        }

        return operation;
    }
}
